Loading...

verticapy.vDataFrame.to_shp

vDataFrame.to_shp(name: str, path: str, usecols: Annotated[str | list[str], 'STRING representing one column or a list of columns'] | None = None, overwrite: bool = True, shape: Literal['Point', 'Polygon', 'Linestring', 'Multipoint', 'Multipolygon', 'Multilinestring'] = 'Polygon') → vDataFrame

Creates a SHP file of the current vDataFrame relation. For the moment, files will be exported in the Vertica server.

Parameters

name: str

Name of the SHP file.

path: str

Absolute path where the SHP file is created.

usecols: list, optional

vDataColumn to select from the final vDataFrame relation. If empty, all vDataColumn are selected.

overwrite: bool, optional

If set to True, the function overwrites the index (if an index exists).

shape: str, optional

Must be one of the following spatial classes: Point, Polygon, Linestring, Multipoint, Multipolygon, Multilinestring. Polygons and Multipolygons always have a clockwise orientation.

Returns

vDataFrame

self

Examples

We import verticapy:

import verticapy as vp

Hint

By assigning an alias to verticapy, we mitigate the risk of code collisions with other libraries. This precaution is necessary because verticapy uses commonly known function names like “average” and “median”, which can potentially lead to naming conflicts. The use of an alias ensures that the functions from verticapy are used as intended without interfering with functions from other libraries.

For this example, we will use the Cities dataset.

import verticapy.datasets as vpd

data = vpd.load_cities()
Abc
city
Varchar(82)
Abc
Long varchar(2411724)
1Abu Dhabi
2Amsterdam
3Apia
4Ashgabat
5Bangui
6Budapest
7Bujumbura
8Castries
9Colombo
10Conakry
11Cotonou
12Dakar
13Dublin
14Georgetown
15Havana
16Kuala Lumpur
17København
18Lilongwe
19Ljubljana
20London
21Monrovia
22Oslo
23Panama City
24Paris
25Phnom Penh
26Podgorica
27Pretoria
28Rangoon
29San Marino
30San Salvador
31Seoul
32Suva
33Tegucigalpa
34Tehran
35Thimphu
36Vatican City
37Warsaw
38Yaounde
39Zagreb
40Andorra
41Athens
42Banjul
43Basseterre
44Belgrade
45Bloemfontein
46Bogota
47Brasilia
48Accra
49Addis Ababa
50Ankara
51Antananarivo
52Asmara
53Astana
54Asuncion
55Bamako
56Bangkok
57Beijing
58Berlin
59Brussels
60Buenos Aires
61Chisinau
62Damascus
63Dar es Salaam
64Dhaka
65Djibouti
66Doha
67Jakarta
68Jerusalem
69Kampala
70Kinshasa
71Kuwait
72La Paz
73Lisbon
74Luxembourg
75Madrid
76Manila
77Maputo
78Mbabane
79Melekeok
80Minsk
81Nairobi
82Naypyidaw
83New Delhi
84Nicosia
85Nouakchott
86Palikir
87Port-au-Prince
88Praia
89Quito
90Rome
91Saint George's
92San Jose
93Sarajevo
94Taipei
95Tbilisi
96Tokyo
97Tripoli
98Valletta
99Vienna
100Vilnius
Rows: 1-100 | Columns: 2

Note

VerticaPy offers a wide range of sample datasets that are ideal for training and testing purposes. You can explore the full list of available datasets in the Datasets, which provides detailed information on each dataset and how to use them effectively. These datasets are invaluable resources for honing your data analysis and machine learning skills within the VerticaPy environment.

Let’s create the SHP file of the current vDataFrame.

data.to_shp(
    name = "cities",
    path = "/home/dbadmin/",
    shape = "Point",
)

Note

It will create “cities.shp” file at provided path.

See also

vDataFrame.to_db() : Saves the current structure of vDataFrame to the Vertica Database.