shapefile

Global Raster of geographic distances

删除回忆录丶 提交于 2019-12-04 16:31:54
Im wondering if someone has built a raster of the continents of the world where each cell equals the distance of that cell cell to the nearest shore. This map would highlight the land areas that are most isolated inland. I would imagine this would simply rasterize a shapefile of the global boundaries and then calculate the distances. You can do this with raster::distance , which calculates the distance from each NA cell to the closest non- NA cell. You just need to create a raster that has NA for land pixels, and some other value for non-land pixels. Here's how: library(raster) library

Displaying a Shapefile

冷暖自知 提交于 2019-12-04 16:24:57
I have a shapefile that I want to display. I tried using matplotlib to display it, but I get this: However, when I tried to display using an online website I get this; How can I get the second image? Here is my code: import shapefile import matplotlib.pyplot as plt print("Initializing Shapefile") sf = shapefile.Reader("ap_abl") apShapes = sf.shapes() points = apShapes[3].points print("Shapefile Initialized") print("Initializing Display") fig = plt.figure() ax = fig.add_subplot(111) plt.xlim([78, 79]) plt.ylim([19, 20]) print("Display Initialized") print("Creating Polygon") ap = plt.Polygon

Python Scripts to ingest a shapefile into a PostgreSQL/PostGIS database utilizing shp2pgsql.exe on windows

微笑、不失礼 提交于 2019-12-04 13:43:52
问题 I have a PostgreSQL database hosted on a Windows 2008 Server RT Virtual Machine (Yes I know it should be hosted on a Linux VM but this is what my organization has dictated it be on. Sigh...) Our GIS guys dump a lot of shapefiles into a repository. We would like to have an autoprocess that walks through folder as a scheduled task. We would like to add these into our Postgres geodatabase for some other processes we are currently developing I am looking to walk through large amounts of

How to pick up the information for the nearest associated polygon to points using R?

北战南征 提交于 2019-12-04 12:19:49
问题 I'm figuring out how to do a Intersection (Spatial Join) between point and polygons from shapefiles. My idea is to get the closest points and those points that match completely inside the polygons. In ARGIS there's a function for match option named CLOSEST and they have defined by: "The feature in the join features that is closest to a target feature is matched. It is possible that two or more join features are the same distance away from the target feature. When this situation occurs, one of

Converting a CAD file to a shape file

百般思念 提交于 2019-12-04 12:10:00
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 You should use OGR http://www.gdal.org/ogr/ It is the main program for converting between geographic formats. It is written in C++ but there are also python bindings. It is

Problems converting from shape to topojson

百般思念 提交于 2019-12-04 08:31:19
问题 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 but I can't manage to display it. Any help will be greatly appreciated. This is my workflow so far: 1) Download and unzip the shapefile wget http://mapserver.inegi.org.mx/MGN/mgm2010v5_0a.zip unzip mgm2010v5_0a.zip 2) Converting to JSON, reprojecting to lat-long and subsetting the shapefile

Convert table of coordinate to shape file using R

本秂侑毒 提交于 2019-12-04 06:20:19
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 create shapefile using R. My code is: library(maptools) library(rgdal) library(sp) UTMcoor=read.csv(file="https://dl.dropboxusercontent.com/u/549234/s1.csv") coordinates(UTMcoor)=~X+Y proj4string(UTMcoor)=CRS("++proj=utm +zone=48") # set it to UTM LLcoor<-spTransform(UTMcoor,CRS("+proj=longlat")) #set it to Lat Long plot(LLcoor) points(LLcoor$X,LLcoor$Y,pch=19,col="blue",cex=0.8) #to test if coordinate can be plot as point map writeOGR

Changing the Projection of Shapefile

这一生的挚爱 提交于 2019-12-04 03:32:59
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 Example: Shapefile and other files can be downloaded here : What I tried is the following: library(maptools) library(sp) library(rgeos) library(rgdal) projection.x <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs +towgs84=0,0,0") mapG <- readShapePoly("vg2500_lan.shp", verbose=TRUE, proj4string=projection.x) summary(mapG) mapG <- spTransform(mapG, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84"))

Read shape file with readOGR verses readShapePoly

流过昼夜 提交于 2019-12-04 00:27:30
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 downloaded the file orcounty.shp from here: http://geography.uoregon.edu/geogr/topics/maps.htm I also downloaded the associated files: orcounty.shx , orcounty.sbx , orcounty.sbn , and orcounty.dbf and put all five files in the folder: c:/users/mark w miller/gis_in_R/shapefile_example/ The following code reads the shapefile and displays some attributes: library(maptools) setwd('c:/users/mark w miller/gis

Adding custom Feature attributes to ESRI Shapefile with Python

这一生的挚爱 提交于 2019-12-03 14:48:53
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 missing an OGR function that will allow me to insert Feature attribute fields into an existing Shapefile?