Loading...

verticapy.vDataFrame.to_shp#

vDataFrame.to_shp(name: str, path: str, usecols: str | list[str] | 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)
1Abidjan
2Abu Dhabi
3Abuja
4Accra
5Addis Ababa
6Algiers
7Amman
8Amsterdam
9Andorra
10Ankara
11Antananarivo
12Apia
13Ashgabat
14Asmara
15Astana
16Asuncion
17Athens
18Baghdad
19Baku
20Bamako
21Bandar Seri Begawan
22Bangkok
23Bangui
24Banjul
25Basseterre
26Beijing
27Beirut
28Belgrade
29Belmopan
30Berlin
31Bern
32Bishkek
33Bissau
34Bloemfontein
35Bogota
36Brasilia
37Bratislava
38Brazzaville
39Bridgetown
40Brussels
41Bucharest
42Budapest
43Buenos Aires
44Bujumbura
45Cairo
46Canberra
47Cape Town
48Caracas
49Castries
50Chisinau
51Colombo
52Conakry
53Cotonou
54Dakar
55Damascus
56Dar es Salaam
57Dhaka
58Dili
59Djibouti
60Doha
61Dublin
62Dushanbe
63Freetown
64Funafuti
65Gaborone
66Georgetown
67Guatemala
68Hanoi
69Harare
70Hargeysa
71Havana
72Helsinki
73Honiara
74Islamabad
75Jakarta
76Jerusalem
77Johannesburg
78Juba
79Kabul
80Kampala
81Kathmandu
82Khartoum
83Kiev
84Kigali
85Kingston
86Kingstown
87Kinshasa
88Kuala Lumpur
89Kuwait
90København
91La Paz
92Libreville
93Lilongwe
94Lima
95Lisbon
96Ljubljana
97Lome
98London
99Luanda
100Lusaka
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.