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