shapefile

Querying data in MySQL Geometry data type column

一个人想着一个人 提交于 2019-12-06 13:55:12
问题 I have a table that stores polygons in a GEOMETRY data type column that I loaded via a shapefile using ogr2ogr. Here's the create statement: CREATE TABLE IF NOT EXISTS `sunzones` ( `OGR_FID` int(11) NOT NULL AUTO_INCREMENT, `polygon` geometry NOT NULL, UNIQUE KEY `OGR_FID` (`OGR_FID`), SPATIAL KEY `polygon` (`polygon`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=105 ; Here is a sample record: POLYGON((449455.354522821 2447255.57758461,449700.419971925 2447132.08575524,449970

Properly scale a vector to fit a raster layer

岁酱吖の 提交于 2019-12-06 11:48:15
So I've created a clipped and reprojected raster image from a Natural Earth 2 data set. It is simple enough to set that as a base layer and project a vector layer on top of it. The problem I'm having is properly scaling the images so they align perfectly. Please refer to this block for the example: http://bl.ocks.org/mkessy/8545864 Here is what I've done so far: Use gdalwarp to reproject the raster to Albers Equal Area and clip to the bounding box of North Dakota, output the image to my desired resolution (960 x 500) In D3 I use the exact same projection and overlay the vector onto the raster

mapping by ggplot2 geom_polygon goes crazy after merging data

房东的猫 提交于 2019-12-06 08:36:22
I am trying to make a grid containing maps of megaregions in the us. I create a SpatialPolygonDataframe from a shape file. then convert it into a data.frame to use ggplot2. as soon as I add the data into the frame, the polygon plots. the file containing SpatialPolygon and the data frame are here: https://drive.google.com/open?id=1kGPZ3CENJbHva0s558vWU24-erbqWUGo the code is as follow: load("./data.rda") prop.test <- proptest.result[which(proptest.result$variable=="Upward N"),] #transforming the data # add to data a new column termed "id" composed of the rownames of data shape@data$id <-

Displaying a Shapefile

让人想犯罪 __ 提交于 2019-12-06 07:21:37
问题 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(

Shade states of a country according to dictionary values with Basemap

試著忘記壹切 提交于 2019-12-06 05:49:41
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.geometry import Polygon mexican_states_people = {'AGS': 20,'BC': 57, 'BCS': 562, 'CAMP': 594,'CHIH':

gdal/ogr: How to really crop a shapefile?

心已入冬 提交于 2019-12-05 22:54:18
问题 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 dots/geometries which intersects my defined area with gdal ? so my crop indeed is a real crop, which just keep the necessary geometries. Strong preference to gdal , ogr or console solutions. 回答1: Use GDAL's ogr2ogr command-line utility. If you have a file Europe.shp which has a spatial reference

Plotting topojson file with d3.js (NYC boroughs and census tracts)

僤鯓⒐⒋嵵緔 提交于 2019-12-05 22:44:31
here is the first topojson question on so. I am having problems rendering a map (NYC boroughs) and can't figure out why. The code below is just a copy of this example with a different topojson file. I have uploaded the file here . Below are also the details about how I created the file. Right now, I am just getting chaotic lines. Probably, the reason is the topojson file but I don't know what's wrong. ps: I was unable to tag this as topojson because the tag has not been used before TopoJSON file 1) Download shapefile from here (Under “Borough & Community Districts” the file “Boroughs” (left),

Intersections of 3D polygons in python

柔情痞子 提交于 2019-12-05 21:17:05
Are there any open source tools or libraries (ideally in python) that are available for performing lots of intersections with 3D geometry read from an ESRI shapefile? Most of the tests will be simple line segments vs polygons. I've looked into OGR 1.7.1 / GEOS 3.2.0, and whilst it loads the data correctly, the resulting intersections aren't correct, and most of the other tools available seem to build on this work. Whilst CGAL would have been an alternative, it's license isn't suitable. The Boost generic geometry library looks fantastic, but the api is huge, and doesn't seem to support wkt or

Troubleshooting topojson installation

倾然丶 夕夏残阳落幕 提交于 2019-12-05 20:03:56
I'm new at this an essentially have very little idea of what I'm doing. (FYI I'm working off of this tutorial: http://bost.ocks.org/mike/map/ ) I'm trying to get topojson to work. I've successfully installed homebrew and node. I've done the "npm install -g topojson" part as well. And then, after that, when I try to type in the "which ogr2ogr" etc -- just, nothing happens. He says if having trouble to edit path variable environments. I have only a vague idea of what that means, and not sure if that's my problem or not. Let me know what other information you need. I really just want to make a

How can I plot shapefile loaded through fastshp in ggplot2?

六月ゝ 毕业季﹏ 提交于 2019-12-05 19:47:09
I stumbled upon fastshp library and according to description (and my quick cursory tests) it really does offer improvements in time of reading large shapefiles compared to three other methods . I'm using read.shp function to load exemplary dataset from maptools package: library("maptools") setwd(system.file("shapes", package="maptools")) shp <- read.shp("columbus.shp", format="polygon") I chose 'polygon' format since accordng to docs : This is typically the preferred format for plotting. My question is how can I plot these polygons using ggplot2 package? Since read.shp in the fastshp package