Questions tagged [shapefile]

The Esri shapefile or simply a shapefile is a popular geospatial vector data format for geographic information systems (GIS) software. Questions about shapefiles are best asked on the GIS Stack Exchange.

Filter by
Sorted by
Tagged with
71 votes
7 answers
125k views

Best way to overlay an ESRI shapefile on google maps?

What is the best way to overlay a shapefile in Google Maps? After some reading suggests that, converting shapefile into KML and overlaying KML in Google map is an option. If that is the case, how do ...
Carsen's user avatar
  • 719
61 votes
5 answers
47k views

Does anyone know of a library in Java that can parse ESRI Shapefiles?

I'm interested in writing a visualization program for the road data in the 2009 Tiger/Line Shapefiles. I'd like to draw the line data to display all the roads for my county. The ESRI Shapefile or ...
KingNestor's user avatar
47 votes
3 answers
104k views

Need the path for particular files using os.walk() [duplicate]

I'm trying to perform some geoprocessing. My task is to locate all shapefiles within a directory, and then find the full path name for that shapefile within the directory. I can get the name of the ...
Schack's user avatar
  • 883
38 votes
4 answers
52k views

How/Where do I get geoJSON data for states, provinces, and administrative regions of non-US countries? [closed]

I need geoJSON formatted paths for states, provinces, and regions within multiple countries. Most readily available geoJSON data is for US states and country level boundaries, not regions within the ...
bburrier's user avatar
  • 1,419
37 votes
4 answers
40k views

sp::over() for point in polygon analysis

I have a shapefile named "ind_adm" and a SpatialPointsDataFrame called "pnts". The "pnts" contains points generated at random, and some of the points overlap with the polygon. See picture below. Now, ...
DotPi's user avatar
  • 4,067
37 votes
2 answers
54k views

Clipping raster using shapefile in R, but keeping the geometry of the shapefile

I am using {raster} to clip (or crop) a raster based on an irregular shapefile (the Amazon biome) but the output always has a rectangular extent. However, I need the output in the exact same geometry ...
ALSM's user avatar
  • 657
29 votes
7 answers
52k views

Check if a geopoint with latitude and longitude is within a shapefile

How can I check if a geopoint is within the area of a given shapefile? I managed to load a shapefile in python, but can't get any further.
Gerald Bäck's user avatar
25 votes
3 answers
39k views

Shapefile into geojson conversion python 3

output_buffer = [] for features in range(0,layer.GetFeatureCount()): feat = layer.GetNextFeature() geom = feat.GetGeometryRef() result = feat.ExportToJson() output_buffer.append(result)...
Vas's user avatar
  • 405
25 votes
7 answers
72k views

Is there any free DBF file converter? [closed]

I have only found trial versions of these converters. Does anyone know a free one? Any of the following target formats will do: CSV, MDB, SQL, XLS
Jader Dias's user avatar
  • 89.4k
24 votes
4 answers
47k views

Set SHAPE_RESTORE_SHX config option to YES to restore or create it

I am not able to read the shape file. It says no such working directory. !pip install sentinelsat !pip install geopandas !pip install folium from sentinelsat import SentinelAPI user = '****' ...
Nikhil Kumar Macharla's user avatar
24 votes
1 answer
22k views

Create convex hull polygon from points and save as shapefile

Needing some help re a conversion problem in R. I've got calculated the convex hull of a cloud of points. I'd like, from the points forming the convex hull, to build a polygon object and save that as ...
user3310782's user avatar
20 votes
5 answers
9k views

Different legends and fill colours for facetted ggplot?

Sorry for not included any example data for my problem. I couldn’t find a way to easily produce an example shape file. Hopefully, experienced users of ggplot can see what I’d like to do from the ...
donodarazao's user avatar
  • 2,813
19 votes
6 answers
24k views

Shapefile reader in Python?

Are there any libraries that I can use to read a shp/shx/dbf/sbx set of files? I mainly need to extract some polygons but something that lets me extract any data that I want would be awesome.
Zameer Manji's user avatar
  • 3,015
19 votes
7 answers
38k views

Error opening SHP file in R using maptools readShapePoly

I am new to R and was following the following tutorial on the ggplot2 package found here. However the readShapePoly() function throws an error whenever I try to load the basic shapefile. I have used ...
Steve Senior's user avatar
18 votes
3 answers
31k views

Intersecting Points and Polygons in R

I am working with shapefiles in R, one is point.shp the other is a polygon.shp. Now, I would like to intersect the points with the polygon, meaning that all the values from the polygon should be ...
Jens's user avatar
  • 2,392
17 votes
1 answer
21k views

Add Polygons to R shiny leaflet map

How do I add polygons from Global Administrative areas, so they are clickable. The simple way describe in the docs that I tried is adm <- getData('GADM', country='UKR', level=1) leaflet() %>% ...
romants's user avatar
  • 3,700
16 votes
4 answers
9k views

How to generate shapefiles for H3 hexagons in a particular area

I would like to generate shapefiles for H3 hexagons in a specific geographic area. Particularly, I'm interested in the Bay Area with resolutions = 6, 7 and 9. How can I create the shapefiles for the ...
Ying Cao's user avatar
  • 161
16 votes
3 answers
10k views

Python: how to create a choropleth map out of a shapefile of Canada?

My goal here is to create a choropleth map of Canada in Python. Suppose I have a dictionary with values referring to each Canadian province/territory: myvalues={'Alberta': 1.0, 'British Columbia': 2....
FaCoffee's user avatar
  • 7,759
15 votes
2 answers
17k views

Which C++ library for ESRI shapefiles to choose?

Does anyone have an experience in processing (reading) ESRI shapefiles from C++? I have found at least 2 open source libraries: ShapeLib C library and OGR. Which one is better? Does anybody used one ...
Sergey Borodavkin's user avatar
15 votes
1 answer
17k views

R How do I merge polygon features in a shapefile with many polygons? (reproducible code example)

How do I merge polygon features in a shapefile with many polygons? rbind and union just combine the rows of the shapefile features, they don't actually merge the polygons themselves. Desired result ...
Neal Barsch's user avatar
  • 2,871
14 votes
1 answer
8k views

Reading shape file with sf::st_read fails to capture encoding UTF8

I want to read a shape file which is encoded in UTF8. It works fine when I read it using rgdal::readOGR but sf::st_read fails to get the correct Encode. Any suggestions on how to solve this? For a ...
rafa.pereira's user avatar
  • 13.5k
14 votes
1 answer
23k views

Changing the Projection of Shapefile

I am trying to change or assign the projection of a Germany-Shapefile from NA to +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0, but somehow it doesn't work well. Reproducible ...
And_R's user avatar
  • 1,647
14 votes
4 answers
25k views

Read shape file with readOGR verses readShapePoly

I have read a shapefile using readShapePoly in the maptools package, but cannot read that same file with readOGR. I am hoping someone may be able to help me read the shapefile with readOGR. I ...
Mark Miller's user avatar
  • 12.8k
13 votes
4 answers
38k views

GDAL, ogr2ogr "Cannot find proj.db" Error

I've tried to extract certain country from the world shp file from natural earth. I am currently using windows 10, so I installed python 3.7, gdal to use the ogr2ogr. I typed the below code in the ...
Yang JongHyun's user avatar
13 votes
1 answer
12k views

Get feature extent using gdal/ogr

This feels like something that should already have a function to do easily, but I can't find one. What I'm ultimately trying to do: I have a shapefile with 3 features that show bounding boxes; I want ...
Jessica's user avatar
  • 525
13 votes
1 answer
44k views

in R, save a shapefile

I would like to save a shapefile after a manipulation. First, I read my object map<-readOGR("C:/MAPS","33SEE250GC_SIR") After this, I subset my shapefile: test <- fortify(...
MAOC's user avatar
  • 625
12 votes
1 answer
2k views

Problems converting from shape to topojson

I'm trying to convert a shapefile of mexican municipalities into a topojson and displaying it using d3.js using this tutorial http://bost.ocks.org/mike/map/#converting-data. I've managed to convert it ...
eclark's user avatar
  • 819
12 votes
1 answer
4k views

Creating shapefiles from points in data frame

After reading a lot of posts and websites I can't find out how to create a polygon shapefile from my lon-lat data table. I would like to create maps like this one. My csv data file contains longitude,...
pacomet's user avatar
  • 5,111
11 votes
2 answers
20k views

How to Import shape file into MySQL

I need to import the spatial data in shape file into MySQL tables. I am able to import into PostGreSQL. Any pointers for MySQL. I need the data in MySQL table.
PhantomM's user avatar
  • 835
11 votes
5 answers
5k views

Random error: Attempted to read or write protected memory

We have a C# .Net application using WCF services. And the application is deployed in our production server under a Windows Service Application. One part of the module is responsible for creating ...
franklins's user avatar
  • 3,730
10 votes
4 answers
15k views

combining multiple shapefiles in R

I have a folder with about 100 point shapefiles that are locations obtained while scat sampling of an ungulate species. I would like to merge all these point shapefiles into one shapefile in R. All ...
V.Menon's user avatar
  • 101
10 votes
2 answers
14k views

SpatialPolygonDataFrame plotting using ggplot

I have a shape file for the greater London area. I use the readShapePoly function from the maptools package to load it in R as a SpatialPolygonDataFrame . I want to the plot those polygons .. Which I ...
Moustafa Alzantot's user avatar
10 votes
1 answer
18k views

How to set line width and color when plotting a shapefile with plot()

I have a simple shapefile I want to plot with the general plot() (I noticed that ggplot is extremely slow in plotting maps). I can correctly plot the shape with the code library(maptools) ...
CptNemo's user avatar
  • 6,625
10 votes
4 answers
8k views

Exporting a Geopandas dataframe to a zipped shapefile directly

I'm trying to save Geopandas data frame into a shapefile that is written to a zipped folder directly. As any shapefile user knows, a shapefile is not a single file but rather a collection of files ...
saQuist's user avatar
  • 436
10 votes
1 answer
10k views

gdal/ogr: How to really crop a shapefile?

Given a SHP file corresponding to European countries, and... Given defined area corresponting to France such : West : 005° 48' W East : 010° E North : 051° 30' N South : 041° N How to get only the ...
Hugolpz's user avatar
  • 17.8k
10 votes
1 answer
6k views

Problem with a column name contains a colon in PostgreSQL

I downloaded the shape data from OSM. I have imported data from Shapefile into PostgreSQL without any problem but I got an error when I do the select statement. Select addr:city From location; Error:...
Vorleak Chy's user avatar
10 votes
2 answers
6k views

How to extract vertexes of geometries in ESRI shapefiles using ogr library with c++

I have answered the question and also changed the title of the question from How to access vertices in a polygon layer using ogr library with c++ to How to extract vertexes of geometries in ESRI ...
Sepideh Abadpour's user avatar
10 votes
2 answers
22k views

Creating Shapefiles in R

I'm trying to create a shapefile in R that I will later import to either Fusion Table or some other GIS application. To start,I imported a blank shapefile containing all the census tracts in Canada. ...
user2142810's user avatar
  • 1,143
10 votes
6 answers
6k views

How to export contours created in scikit-image find_contours to shapefile or geojson?

I'm trying to export the results of the scikit-image.measure.find_contours() function as a shapefile or geojson after running on a satellite image. The output is an array like (row, column) with ...
Cate's user avatar
  • 431
10 votes
1 answer
9k views

How to run GDAL (ogr2ogr) in Java to convert Shapefiles to GeoJSON

I'm a beginner at programming and get pretty confused when trying to use external libraries. I have my maps in shapefiles that I convert to GeoJSON using the website Mapshaper.org, and only then can i ...
user29903's user avatar
  • 101
10 votes
3 answers
15k views

Manipulate shapefile attribute table using R

I've posted this question on the GIS stack exchange, but it's not seeing much traffic. I'm a GIS user who's been using R for stats for a few years, and I'm excited to see a lot of new GIS ...
RichT's user avatar
  • 304
9 votes
1 answer
23k views

Export a polygon from an R plot as a shapefile

I have been trying to export the content of a plot (lines/polygons) as a layer/shapefile that I can open in ArcMap. These are some of the libraries that I have been using, library(shapefiles) library(...
user1626688's user avatar
  • 1,623
9 votes
1 answer
15k views

Shapefile to raster conversion in R?

I have a shapefile downloaded from the worldwildlife.org for the terrestrial ecoregions of the world. The file can be loaded here: http://worldwildlife.org/publications/terrestrial-ecoregions-of-the-...
I Del Toro's user avatar
9 votes
1 answer
22k views

Add legend to geopandas

I have a map of Chile (http://labgeo.ufro.cl/fichas/chile_geo/ficha_cl_geo.html first link that says "Chile continental) and would like to plot it and add some points of centers for which I have ...
Isa's user avatar
  • 113
9 votes
1 answer
12k views

Reading shapefile coordinates in c#

I want to draw a polyline on "XAML Map Control" with latitude/longitude, using the content of a shapefile. I have 2 types of shapefile: One with .dbf, .prj, qpj, .shx and obviously .shp file. One ...
iRubens's user avatar
  • 315
9 votes
2 answers
2k views

Read only data slot from shapefile (R)?

I have some very large shapefiles. I can read them into SpatialPolygonsDataFrame's using the rgdal function readOGR, but it takes a very long time for each file. I am actually only interested in the ...
attitude_stool's user avatar
8 votes
2 answers
17k views

Projecting my shapefile data on leaflet map using R

I (on Win7) was trying to get my shapefile data (Here are the data files.) to be displayed using leaflet package. But without any success. I only get the background map tile but not my data. I am able ...
Stat-R's user avatar
  • 5,160
8 votes
4 answers
25k views

shapefile and matplotlib: plot polygon collection of shapefile coordinates

I'm trying to plot filled polygons of countries on the world map with matplotlib in python. I've got a shapefile with country boundary coordinates of every country. Now, I want to convert these ...
hannesk's user avatar
  • 439
8 votes
1 answer
4k views

Unzipping and reading shape file in R without rgdal installed

I would like to unzip and read in a shape file from the web in R without relying on rgdal. I found the read.shp function of the fastshp package that can apparently accomplish this without rgdal ...
Cyrus Mohammadian's user avatar
8 votes
1 answer
9k views

cant connect to postgres with GDAL ogr2ogr remotely

I am trying to insert a shapefile into PostgreSQL via Gdal ogr2ogr, the command looks like this: ogr2ogr -f 'PostgreSQL' PG:dbname='dbname',user='user',host='172.17.2.176',password='password',port='...
Marcus Ruddick's user avatar

1
2 3 4 5
41