shapefile

How do I import an openstreetmaps shape file in R and extract lat/long centroids?

不问归期 提交于 2020-01-04 05:39:29
问题 I am trying to import an openstreetmaps shape file in R using the rgdal package. The shape file I downloaded has 5 components in it: places.cpg places.dbf places.prj places.shp places.shx The files can be accessed at the following location: https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc I have to do the following: 1) Import the shape file 2) Extract lat/long of the point or centroid of shape in case of polygon 3) Attach the lat/long pair to the dbf file to do some analysis I am

Shade states of a country according to dictionary values with Basemap

▼魔方 西西 提交于 2020-01-02 18:52:47
问题 I want to plot the map of Mexico and shade the states accordingly to a the values of a dictionary. I used the following code suggested in previous question (Easiest way to plot data on country map with python), so far it plots the country and states, but when I try to define the shading I get an error. Below the code: import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import PatchCollection from mpl_toolkits.basemap import Basemap %matplotlib inline from shapely

gSimplify not simplifying shapefile in R

删除回忆录丶 提交于 2020-01-02 08:53:48
问题 I'm unable to simplify a shapefile in R Shapefile from here: https://geoportal.statistics.gov.uk/Docs/Boundaries/Local_authority_district_(GB)_2014_Boundaries_(Generalised_Clipped).zip library(tmap) library(maptools) library(ggmap) England <- readOGR(dsn = "...") #works fine print(qtm(England, "LAD14CD", borders = NA, fill.title = "A-Level" )) # simplify the polygons England<-gSimplify(England,tol=0.01, topologyPreserve=TRUE) print(qtm(England, "LAD14CD", borders = NA, fill.title = "A-Level"

Converting a CAD file to a shape file

杀马特。学长 韩版系。学妹 提交于 2020-01-01 15:03:45
问题 Thanks for the assist on my previous question.... I was able to complete my project This time I have a CAD file created with Autodesk that I need to convert to a shape file. Couple of questons: An open source application (can't afford ESRI) that can convert the CAD file to a shape file? Is that a better file format I can use other than the shape file (shp) format? Any suggestions would be greatly appricated Regards Chris 回答1: You should use OGR http://www.gdal.org/ogr/ It is the main program

Adding custom Feature attributes to ESRI Shapefile with Python

孤街醉人 提交于 2020-01-01 05:16:11
问题 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 arbitrary (for now) additional attribute, say, "POPULATION". Of course I have the OSGeo and GeoDjango modules installed. I'm as far as: from osgeo import ogr infile = ogr.Open('sample.shp', 1) #'sample.shp' is a pre-existing ESRI shapefile described above inlyr = infile.GetLayerByIndex(0) Am I

Projecting my shapefile data on leaflet map using R

拜拜、爱过 提交于 2019-12-31 10:38:13
问题 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 to see my data in QGIS though. I got the following code and description from here. library(rgdal) shapeData <- readOGR(".",'myGIS') ogrInfo(".",'myGIS') leaflet() %>% addTiles() %>% setView(lng = -106.363590, lat=31.968483,zoom=11) %>% addPolygons(data=shapeData,weight=5,col = 'red') %>%

Projecting my shapefile data on leaflet map using R

筅森魡賤 提交于 2019-12-31 10:37:44
问题 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 to see my data in QGIS though. I got the following code and description from here. library(rgdal) shapeData <- readOGR(".",'myGIS') ogrInfo(".",'myGIS') leaflet() %>% addTiles() %>% setView(lng = -106.363590, lat=31.968483,zoom=11) %>% addPolygons(data=shapeData,weight=5,col = 'red') %>%

From a shapefile with polygons/areas, and points (lat,lon), figure out which polygon/area each point belongs to? In R

…衆ロ難τιáo~ 提交于 2019-12-31 04:32:06
问题 I am trying to identify which polygon (ZCTA... aka Zip Code analogue) a given point belongs in, given a set of points and a shapefile. While there are several questions of this type out there, nearly all seem to refer me toward QGIS. While I'll go and learn another tool if needed, is there a simple way to do this in R? I'm experienced in the R environment... not so much in the GIS space. The shapefile I am using is located here: ftp://ftp.gisdata.mn.gov/pub/gdrs/data/pub/us_mn_state_mngeo

How to know if topojson is installed and working normally?

北城余情 提交于 2019-12-30 14:49:42
问题 How to know if topojson is well installed and working normally? An example tiny file to convert will be appreciate. with both the source and expected result 回答1: If you haven't stumbled across this yet I found it to be a great walkthrough of the entire process: http://bost.ocks.org/mike/map/ The above link also includes the command to run to check if topojson is installed: $which topojson If topojson is installed correctly this will print out the directory where it's installed, which might

Filling shapefile polygons with a color in matplotlib

陌路散爱 提交于 2019-12-29 07:59:23
问题 I am searching way to fill polygons of a shapefile based on a value. So far from basemap tutorial (http://basemaptutorial.readthedocs.io/en/latest/shapefile.html) i 've found how to fill the polygons with a specific color. import matplotlib.pyplot as plt import pypyodbc from mpl_toolkits.basemap import Basemap from matplotlib.patches import Polygon from matplotlib.collections import PatchCollection from matplotlib.patches import PathPatch import numpy as np fig= plt.figure() ax= fig.add