shapefile

How to plot a shapefile centered in the Pacific with Basemap?

谁都会走 提交于 2019-12-08 09:38:38
问题 When plotting with Basemap's readshapefile , if the defined map is centered anywhere else than the longitudinal center of the shapefile, only a portion of it it's plotted. Here's an example using Natural Earth's coastlines: import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap shpf = './NaturalEarth/ne_50m_land/ne_50m_land' fig, ax = plt.subplots(nrows=1, ncols=1, dpi=100) m = Basemap( ax = ax, projection = 'cyl', llcrnrlon = 0, llcrnrlat = -90, urcrnrlon

Create shapefile from tif file using GDAL

人走茶凉 提交于 2019-12-08 04:01:58
问题 I am using library gdal to load a tiff file and create a shapefile. When I load my shapefile with QGIS GUI, There are no informations on the elevation. I would like to keep the elevation while the transformation. import os from osgeo import gdal,ogr,osr,gdalnumeric import numpy as np # this allows GDAL to throw Python Exceptions gdal.UseExceptions() print "reading tif file..." try: ds = gdal.Open( "file.tif" ) except RuntimeError, e: print 'Unable to open file' print e sys.exit(1) try:

mapping by ggplot2 geom_polygon goes crazy after merging data

自古美人都是妖i 提交于 2019-12-08 02:37:52
问题 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

Properly scale a vector to fit a raster layer

折月煮酒 提交于 2019-12-08 02:12:12
问题 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

How can I plot shapefile loaded through fastshp in ggplot2?

 ̄綄美尐妖づ 提交于 2019-12-07 17:27:31
问题 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

SpatialPolygonDataFrame plotting using ggplot

你。 提交于 2019-12-07 16:15:17
问题 I am having a shape file for the greater London area. I use the readShapePoly function from the maptools package to load it in R as a SpatialPolygonDataFrame . I want to the plot those polygons .. Which I have already done by using the basic of plot function in R. The output looks as shown in this image: Now, I am trying to plot the same shape file using ggplot2 but it doesn't work with me. I am getting some weird lines in the graph as shown blew: The code I used was : london.wards <-

Overlaying shapefiles or raster over interactive maps

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-07 05:40:41
问题 I'm using R, and I want to overlay some raster data (e.g. a temperature map from a model) over an interactive map which allows panning and zooming. Ideally, I'd like to overlay over Google Maps or OpenStreetMaps. The input data can be in shapefiles, KML, raster data or whatever comes in handy. I know I can easily do this non-interactively using either googleVis , ggmap or RgoogleMaps . But I do not want to use tiles, I want interaction ! Zooming, panning etc., directly from the browser.

TimeZone by Coordinate [duplicate]

馋奶兔 提交于 2019-12-07 01:02:29
问题 This question already has answers here : How to get a time zone from a location using latitude and longitude coordinates? (15 answers) Closed 4 months ago . 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 there but I need to be able to access the application offline. As the timezones isn't completely based on longitude it doesn't seem that easy

b'Recode from ANSI 1252 to UTF-8 failed with the error: “Invalid argument”.' geopandas python

為{幸葍}努か 提交于 2019-12-07 00:23:01
问题 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("wild_fires/nbac_2016_r2_20170707_1114.shp") But this time it gives me the error: b'Recode from ANSI 1252 to UTF-8 failed with the error: "Invalid argument".' Full error: --------------------------------------------------------------------------- CPLE_AppDefinedError Traceback (most recent call last)

How can I transform the coordinates of a Shapefile?

天涯浪子 提交于 2019-12-06 22:45:02
问题 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 Francisco. I am running a Ruby on Rails framework, and I'm currently using GeoRuby to parse the shapefile. The code looks like this: def self.run_import shpfile = '/path/to/realtor_neighborhoods/realtor_neighborhoods' ShpFile.open(shpfile) do |shp| shp.each do |shape| # This gets the first (and only)