shapefile

Extract centroid of shape file object in R?

自闭症网瘾萝莉.ら 提交于 2019-12-13 16:44:17
问题 I have a shape file, uploaded at the following path: https://drive.google.com/open?id=0B1ITb_7lHh1EUFVfVWc4ekRfSnc I imported the data using the "read.shapefiles" function in "shapefiles" package: landuse<- read.shapefile("landuse") I now need to extract the lat/long centroids of all the shapes within the landuse object and add it to the landuse$dbf dataframe I tried two things: lu_df<-coordinates(landuse) lu_df<-SpatialPoints(landuse) Both gave me the following error: Error in coordinates(as

Creating nodes/turtles out of a shp file from GIS General Examples

佐手、 提交于 2019-12-13 15:31:21
问题 I need to create nodes from the cities shapefile of GIS general examples, so I can use them as targets for turtles. I tried the follows solutions but it doesn't work: http://netlogo-users.18673.x6.nabble.com/Creating-nodes-turtles-out-of-a-shp-file-and-linking-them-td5004359.html http://netlogoabm.blogspot.com/2015/07/loading-gis-and-csv-data-to-model-to-be.html#more This is the code: extensions [ gis ] globals [ cities-dataset countries-dataset ] breed [ city-labels city-label ] breed [

Read in all shapefiles in a directory in R into memory

匆匆过客 提交于 2019-12-13 11:18:39
问题 I would like to read all shapefiles in a directory into the global environment However, when I get a list of files in my working directory, the list includes both .shp and .shp.xml files, the latter of which I do not want. My draft code reads both .shp and .shp.xml files. How can I prevent it from doing so? Draft code follows: library(maptools) # get all files with the .shp extension from working directory setwd("N:/Dropbox/_BonesFirst/139_Transit_Metros_Points_Subset_by_R") shps <- dir(getwd

How to display a map using shape files in Android?

北城以北 提交于 2019-12-13 09:47:21
问题 I have tried with below code for read and display shapefile from my SD card ShapefileFeatureTable shapefileFeatureTable = null; try { shapefileFeatureTable = new ShapefileFeatureTable(Environment.getExternalStorageDirectory().getAbsolutePath()+"/India_SHP/INDIA.shp"); featureLayer = new FeatureLayer(shapefileFeatureTable); featureLayer.setRenderer(new SimpleRenderer(new SimpleMarkerSymbol( getResources().getColor(android.R.color.holo_blue_bright), 28, SimpleMarkerSymbol.STYLE.CIRCLE)));

Geojson to shapefile convertion using shapefile library

▼魔方 西西 提交于 2019-12-13 03:02:27
问题 I know I can create a shapefile from a geojson if the shapefile only contains Polygons, but in case there is a MultiPolygon I get the following error: return [min(x), min(y), max(x), max(y)] TypeError: '<' not supported between instances of 'list' and 'float'** In return self.__bbox(self._shapes) method under shapefile.py** Any ideas of how I can overcome this problem would be appreciated. Thanks in advance. import shapefile shape_file_writer = shapefile.Writer(SHAPE_FILE_TYPE) #example of

Changing the Projection of Shapefile

前提是你 提交于 2019-12-12 08:34:02
问题 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

Leaflet JS - changing esri shape into marker on certain zoom level

不羁的心 提交于 2019-12-12 05:38:39
问题 I'm using leaflet.shapefile plugin with Leaflet JS, and I'm trying to change the esri shape/polygon into normal marker icons depending on a certain zoom level The plugin allows me to upload a zipfile onto our webserver, which then is processed by the plugin and added as a layer into Leaflet JS var properties = new L.Shapefile('data/Test.zip', { style: propertyStyle, onEachFeature: propertyOnEachFeature }) What I would like to achieve: when the user zoomed in the polygon shape is visible,

Is there way to optimize speed of shapely.geometry.shape.contains(a_point) call?

烂漫一生 提交于 2019-12-12 01:37:00
问题 We are using a shapely library to check that some random point is not in some prohibited areas stored in a shape file. with fiona.open(path) as source: geometry = get_exclusive_item(source[0]) geom = shapely.geometry.shape(geometry['geometry']) def check(lat, lng): point = shapely.geometry.Point(lng, lat) return not geom.contains(point) But the latest call geom.contains(point) takes about a second to complete. Is there any other faster libraries for python, or could we optimize a shape files

How to use gml or shp files on Google Maps api v3?

我的梦境 提交于 2019-12-11 19:54:08
问题 Does someone know how to use an .gml or .shp file on Google Maps api v3? 回答1: You'll need to convert those files into KML or GeoRSS so that they canbe integrated into the Google Map with the KML and GeoRSS layers: https://developers.google.com/maps/documentation/javascript/layers#KMLLayers 来源: https://stackoverflow.com/questions/9768054/how-to-use-gml-or-shp-files-on-google-maps-api-v3

Adding extra data column to shapefile using convert.to.shapefile in R's shapefiles package

前提是你 提交于 2019-12-11 18:06:29
问题 My goal is very simple, namely to add 1 column of statistical data to a shapefile so that I can use it for example to colour a geographical area. The data are a country file from gadm. To this end I usually use the foreign package in R thus: library(foreign) newdbf <- read.dbf("CHN_adm1.dbf") #original shape file incrdata <- read.csv("CHN_test.csv") #.csv file with same region names column + new data column mergedbf <- merge(newdbf,incrdata) write.dbf(mergedbf,"CHN_New") This achieves what I