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.
2,027
questions
8
votes
4
answers
3k
views
b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' geopandas python
I am trying to read in a shapefile into a GeoDataFrame.
Normally I just do this and it works:
import pandas as pd
import geopandas as gpd
from shapely.geometry import Point
df = gpd.read_file("...
8
votes
1
answer
6k
views
Split or save a subset of a ESRI Shape SHP file to a new file?
I'm working with shape files in GeoDjango. Right now I'm trying to write a test for code that loads in a shape file and saves it to a database. The shape file currently has a feature count of 64,118....
8
votes
2
answers
16k
views
How to import a shape file into SQL Server?
In the past I have used shape2sql to import shape files into SQL Server.
I tried that route again on a newer Windows 10 box, and nothing seems to happen when trying to use that application.
Any ...
8
votes
1
answer
14k
views
R - stuck with plot() - Colouring shapefile polygons based upon a slot value
I have a shapefile showing remote areas in Australia, obtained from the Australian Bureau of Statistics:
http://www.abs.gov.au/AUSSTATS/[email protected]/DetailsPage/1270.0.55.005July%202011?OpenDocument
At ...
8
votes
5
answers
5k
views
TimeZone by Coordinate [duplicate]
As the title infers I need to find a time zone (or perhaps just the UTC offset) based on a pair of coordinates. I've been searching for different solutions, and there is a couple of web services out ...
8
votes
2
answers
7k
views
Android lib to read or parse shapefile
is there any library that is able to read parse a .shp file, preferably on where I don't need to use NDK.
I was trying to use GeoTools but i can't seam to get it to work on Android.
8
votes
4
answers
4k
views
How can I transform the coordinates of a Shapefile?
I am trying to get neighborhood data into my application, and I'm having problems with the data I am using, which I got from here.
This file contains a shapefile that has the neighborhoods of San ...
8
votes
1
answer
941
views
Extract routes between stations from a rail network shapefile
Problem: I want to extract a route along the rail network between two stations from a shapefile and only plot this particular route, rather than the entire network.
This is what I have so far:
I ...
8
votes
1
answer
3k
views
Mask area outside of imported shapefile (basemap/matplotlib)
I'm plotting data on a basemap of the eastern seaboard of the U. S. and Canada through Matplotlib. In addition to the base layer (a filled contour plot), I overlayed a shapefile of this focus region ...
7
votes
5
answers
15k
views
Import shape file into postgis? [closed]
I can find multiple tutorials that show how to import shapefiles to postgis via pgAdmin-3. But pgAdmin-3 is no longer supported.
How to do this with pgAdmin-4?
7
votes
4
answers
11k
views
How to convert shapefile/geojson to hexagons using uber h3 in python?
I want to create hexagons on my geographic map and want to preserve the digital boundary specified by the shapefile/geojson as well.
How do I do it using uber's h3 python library?
I'm new to ...
7
votes
3
answers
12k
views
Automatically fixing ring self-intersections in shp2pgsql
We're importing a whole bunch of ArcGIS shapefiles into PostGIS, converted on the fly with shp2pgsql. Problem is, if the shapefiles have any ring self-intersections, the import chokes:
NOTICE: Ring ...
7
votes
3
answers
10k
views
How to get shapefile geometry type in PyQGIS?
I'm writing a script that is dependent on knowing the geometry type of the loaded shapefile.
but I've looked in the pyqgis cookbook and API and can't figure out how to call it.
infact, I have ...
7
votes
2
answers
3k
views
Shapefile with ObjectiveC
I like to know if there is a Class, in objective-C, that manipulates shapefile (read/write/edit)?
I have found a bunch of stuff on kml files but nothing about shp files, but definitely want to avoid ...
7
votes
4
answers
12k
views
can't open shape file with GeoPandas
I don't seem to be able to open the zip3.zip shape file I download from (http://www.vdstech.com/usa-data.aspx)
Here is my code:
import geopandas as gpd
data = gpd.read_file("data/zip3.shp")
this ...
7
votes
1
answer
4k
views
How do you combine a map with complex display of points in ggplot2?
I'm trying to plot points from study sites with a background map of Africa. I can create the two independently, but I am having a hard time overlaying them on top of eachother.
The map of Africa I ...
7
votes
2
answers
737
views
Algorithm (and tools) to create a weighted-cartogram from a shapefile?
What algorithm can I use to produce a weighted-cartogram such as the one below: ?
I can generate a shapefile plot using code from R, .NET libraries and also using PostGIS. However I can't find the ...
7
votes
2
answers
12k
views
Convert table of coordinate to shape file using R
I have a dataset of point coordinate in UTM zone 48.
x y
615028.3 2261614
615016.3 2261635
614994.4 2261652
The CSV file here.
I would like to load the CSV and ...
7
votes
1
answer
6k
views
Plotting shp file in leaflet, works in ggplot
I'm stumped getting my dataframe to plot in leaflet. I have one shapefile and one csv that I merged together. The resulting dataframe has several columns, including long, lat, and "percent".
I am ...
7
votes
2
answers
7k
views
Python: how to create a point shape-file from a text file
I'm writing a python code to read the points in a polygon shape-file and save them in a point shape file.
So first I made a text file and stored the points' (x,y) in that .txt file. then I tried to ...
6
votes
2
answers
14k
views
Count number of points in multipolygon shapefile using Python
I have a polygon shapefile of the U.S. made up of individual states as their attribute values. In addition, I have arrays storing latitude and longitude values of point events that I am also ...
6
votes
1
answer
8k
views
Plotting polygon shapefiles and geom_points with ggplot2
I've been struggling with this plot and would appreciate any help.
I am trying to plot a polygon over my geom_points. This is what I've done so far:
> names(OT1)# my dataset
[1] "EID" "...
6
votes
2
answers
13k
views
Convert multipolygon geometry into list
How can I please convert a multipolygon geometry into a list?
I tried this:
mycoords=geom.exterior.coords
mycoordslist = list(mycoords)
But I get the error:
AttributeError: 'MultiPolygon' object has ...
6
votes
2
answers
3k
views
Using Shapefile data to determine neighborhood for a longitude/latitude
I'm trying to determine the neighborhood for a location, based on Zillow's freely published Shapefile data.
I don't really know anything about the Shapefile format, and am having some trouble finding ...
6
votes
2
answers
19k
views
Easiest way to plot data on country map with python
Could not delete question. Please refer to question: Shade states of a country according to dictionary values with Basemap
I want to plot data (number of sick people for a certain year) on each ...
6
votes
2
answers
2k
views
How to convert a sample dataset from the R package "spatstat" into a shapefile
I have written a kernel density estimator in Java that takes input in the form of ESRI shapefiles and outputs a GeoTIFF image of the estimated surface. To test this module I need an example shapefile,...
6
votes
2
answers
5k
views
Merging a Shapefile and a dataframe
I am working in R with a regular dataframe (df) and a shapefile (map2), the share a common column called CD116FP. df has 103552 lines while map2 has 444 .I am loading the shapefile in the following ...
6
votes
2
answers
4k
views
UnicodeDecodeError 'utf-8' codec can't decode - using python shapefile reader
I'm trying to read a shapefile
r = shapefile.Reader(filepath, encoding = "utf-8")
but when I try to get a value from the .records() object like:
r.records()[0]
it returns to me the following ...
6
votes
1
answer
14k
views
Geojson to shapefile using Python
I'm trying to convert a geojson file into a shapefile.
I'm trying this way (I'm very new to Python so it might be incorrect).
import urllib, geojson, gdal
url= ' http://ig3is.grid.unep.ch/istsos/wa/...
6
votes
2
answers
1k
views
How to combine state-level shapefiles from the united states census bureau into a nationwide shape
The census bureau doesn't provide a nationwide shapefile of public use microdata areas (the smallest geography available on the American Community Survey). I tried combining them all with a few ...
6
votes
1
answer
3k
views
Mercator projection world map with Geoserver and Openlayers
I'm trying to render a world map shapefile on my Geoserver with a Mercator projection. I've tried declaring the SRS on Geoserver and defining EPSG projections of 3785 or 900913 in Openlayers with no ...
6
votes
1
answer
8k
views
Adding custom Feature attributes to ESRI Shapefile with Python
I am seeking a way to take an existing ESRI Shapefile that has a Feature set of 200 countries. Each country Feature has an attribute of "NAME." My objective is to create a Python script that adds an ...
6
votes
1
answer
4k
views
ggplot2: Combine shapefiles from two different geodatasets
I am trying to plot some geolocational data pertaining to Great Britain and Ireland in ggplot. Running the following code, I can successfully map some values from this tab-separated file onto the GBR ...
6
votes
3
answers
7k
views
How to export WKT from a Shapefile in c#?
I have a Shapefile that contains several thousand polygons.
I need to read from this file in C# and output a list of WKT formatted strings.
I looked at DotSpatial and the "CatFood" ESRI Shapefile ...
6
votes
1
answer
11k
views
How to Convert SVG to SHP (Shape File) format? [closed]
I am trying to convert the SVG File to SHP (Shape File format) and then get it imported into GeoServer.
Is there any convertor available OR is there any mediating format in which I can get it ...
6
votes
2
answers
10k
views
coordinates conversion with pyproj
I am not experienced in gis coordinates conversion but managed, using this page:
http://all-geo.org/volcan01010/2012/11/change-coordinates-with-pyproj/
to convert shapefile coordinates from EPSG:28992 ...
6
votes
2
answers
2k
views
making a choropleth in R: merging zip code shapefiles from multiple states
Motivated by the post here, Developing Geographic Thematic Maps with R, I was thinking about constructing a choropleth map based on zip codes. I've downloaded the shape files for New Hampshire and ...
6
votes
1
answer
2k
views
Reading Unzipped Shapefiles stored in AWS S3 from AWS EMR Cluster using PySpark in Jupyter Notebook
I'm completely new to AWS EMR and apache spark. I'm trying to assign GeoID's to residential properties using shapefiles. I'm not able to read the shapefiles from my s3 bucket. Please help me in ...
6
votes
1
answer
515
views
Python: assign point to roads shapefile
I have some data points from gps data (Lat,Lon) and the relative shapefile of the area I am considering. So:
import pandas as pd
import shapefile
sf = shapefile.Reader('roadshape')
df = pd.read_csv('...
6
votes
1
answer
4k
views
How to use set clipped path for Basemap polygon
I want to use imshow (for example) to display some data inside the boundaries of a country (for the purposes of example I chose the USA) The simple example below illustrates what I want:
import numpy ...
6
votes
2
answers
3k
views
How to limit the raster processing extent using a spatial mask?
I am trying to limit raster processing in MATLAB to include only areas within a shapefile boundary, similar to how ArcGIS Spatial Analyst functions use a mask. Here is some (reproducible) sample data ...
6
votes
3
answers
19k
views
Error with function fortify of ggplot2
I am trying to convert a spatial object into a data.frame using the function fortify from the package ggplot2. But I am getting an error. For example, following the exact same code used in Hadley ...
6
votes
1
answer
3k
views
Using ggplot to plot shapefile and gganimate for animation
Sample data
library(raster)
library(ggplot2)
my.shp <- getData('GADM', country = 'FRA', level = 1)
plot(my.shp)
If I want to plot this data using ggplot:
my.shp_f <- fortify(my.shp, region = ...
6
votes
1
answer
1k
views
spatial join on two simple features {sf} with over 1 mil. entries as fast as possible
I hope this is not too trivial but I really can't find an answer and I'm too new to the topic to come up with alternatives myself. So here is the Problem:
I have two shapefiles x and y that represent ...
6
votes
1
answer
298
views
I want to create a countour map from x, y and z and clip the data with the shapefile using ggplot
I have a data set with Eastings, Northings and Age. I want to plot the age for my data set.
The dataset is upload in the following loation:
https://www.dropbox.com/s/zmtxluhwuupb9iv/age%20at%202100....
6
votes
1
answer
475
views
PHP - Generate kml from 'Point' shape
I'm using PHPShapefile library for generating KML and displaying data to the google map but while it comes to 'Point' shape its not working and not generating KML for same.
Here is the code snippet ...
6
votes
1
answer
2k
views
Displaying shape file or and OSM file in android as a map
I want to implement a Indoor Navigation application in android.
My first task is to display the map in android.
I have created the indoor map in both shape file and OSM file format.
• I created the ...
6
votes
0
answers
2k
views
Write Shapefile to AWS S3 with geopandas in Glue Python Shell
I have read shapefile in a zip format from my S3 bucket successfully through geopandas, but I get error when trying to output the same geodataframe as a shapefile to the same S3 bucket.
The code below ...
6
votes
1
answer
3k
views
rasterFromXYZ() Error in rasterFromXYZ() : x cell sizes are not regular
I am trying to plot points from a df (xyz/latlonvalue) as raster over a geom_sf shapefile. I tried the answers from another post but none of them helped. The data structure is below.
First I try ...
6
votes
2
answers
1k
views
How to upload shapefile into Shiny App
I am trying to figure out how, using Shiny App, a user can submit a shapefile via fileInput and then map it on a leaflet basemap. I am stuck on the server.R script and unsure how to handle the user ...