我有Eastings,Northings和Age的数据集.我想绘制数据集的年龄.数据集按以下方式上传:https://www.dropbox.com/s/zmtxluhwuupb9iv/age%20at%202100.csv
我用来创建简单图形和轮廓的代码如下:
age2100 <- read.csv("age at 2100.csv",header=TRUE, sep=",")
p <- ggplot(age2100, aes(x=Eastings, y=Northings, colour=("Age")))+geom_point()
p+geom_density2d()
Run Code Online (Sandbox Code Playgroud)
我得到的输出如下:
我无法上传图片,因此请在以下保管箱位置找到图片:
https://www.dropbox.com/s/5k5gefqi7wz6v36/age.png
现在,我想在背景上添加shapefile并将轮廓线剪切到shapefile.
所需的输出如下:
https://www.dropbox.com/s/tqhx2t8cqqozwbt/7Q10%20flow%20dye%20from%20P%20and%20S.JPG
如何从图1进入所需的输出?如果有人能给我建议,那就太好了.
非常感谢.
Jdbaba
我想用顶部形状文件中的点绘制一个栅格图层。我已经检查了之前的答案,但仍然有问题。我可以毫无问题地分别绘制点形状文件和栅格图层,但不能一起绘制。
据我所知,它们应该位于相同的投影和位置。
require(maptools)
myproj <- "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
shape <- readShapeSpatial("directory/mypoints.shp", proj4string = CRS(myproj))
plot(r <- raster(listVI[200]))
plot(shape)
Run Code Online (Sandbox Code Playgroud) 我有一个形状文件,我想用 ggplot 将其发布在谷歌地图上,但是通过 geom_polygon(ggplot2) 发布会显示没有意义的线条
我的代码:
######## the shape file ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/Brasil/BR/
download.file("ftp://geoftp.ibge.gov.br/organizacao_do_territorio/malhas_territoriais/malhas_municipais/municipio_2015/Brasil/BR/br_municipios.zip",temp)
data <- unz(temp, "BRMUE250GC_SIR.shp")
data.shape<-st_read(data)
####### the map from ggmap
mapa_edital_guarulhos <- get_map(location="GUARULHOS-SP",zoom=11,color = "bw",
maptype = "roadmap")
mapa_edital_guarulhos_01<- ggmap(mapa_edital_guarulhos)
########## plotting with ggplot
mapa_edital_guarulhos1 <- mapa_edital_guarulhos_01 +
geom_polygon(aes(x=long,y=lat, group=group), data=shape.sp,
color='black',alpha=0)
Run Code Online (Sandbox Code Playgroud)
结果:
箭头显示的线条在我的图中没有意义,仅绘制相同间隔的形状:
plot(shape.sp,xlim=c(-47.25,-46.95),ylim=c(-23.1,-22.7))
Run Code Online (Sandbox Code Playgroud)
我的代码有什么问题吗?谢谢
我对 AWS EMR 和 apache Spark 完全陌生。我正在尝试使用 shapefile 将 GeoID 分配给住宅物业。我无法从我的 s3 存储桶中读取 shapefile。请帮助我了解发生了什么,因为我在互联网上找不到任何解释确切问题的答案。
<!-- language: python 3.4 -->
import shapefile
import pandas as pd
def read_shapefile(shp_path):
"""
Read a shapefile into a Pandas dataframe with a 'coords' column holding
the geometry information. This uses the pyshp package
"""
#read file, parse out the records and shapes
sf = shapefile.Reader(shp_path)
fields = [x[0] for x in sf.fields][1:]
records = sf.records()
shps = [s.points for s in sf.shapes()]
center = [shape(s).centroid.coords[0] …Run Code Online (Sandbox Code Playgroud) I have a folder with about 100 point shapefiles that are locations obtained while scat sampling of an ungulate species. I would like to merge all these point shapefiles into one shapefile in R. All the point data were in .gpx format initially which I then changed to shapefiles.
我对 R 相当陌生,所以我对如何做到这一点感到非常困惑,并且找不到合并或组合多个 shapefile 的代码。任何建议将不胜感激。谢谢!
例如:[360590, 555610] - [lng, lat] 以米为单位来自谷歌地图 api - GeoJson 数据
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "MultiPolygon",
"coordinates": [
[
[
[
360590,
555610
],
[
360590,
555555.0128
],
[
360590,
555540
],
[
360592.4439,
555540
],
[
360600,
555540
],
[
360600,
555518.8277
]
]
]
]
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
这里,[360590, 555610] - [X, Y] 坐标以米为单位,现在我们需要在谷歌地图上显示这个坐标,有什么解决办法吗?
我们还必须使用 addGeoJson 或 loadGeoJson 方法,因为我们在 GeoJson 文件中有 200MB 数据。现在我们需要在谷歌地图上显示这个坐标,有什么解决办法吗?
我想绘制一个shapefile使用 geopandas 的图。我希望线条的粗细符合shapefile. 我为此使用以下命令:
shp_sub.plot(column='Case1_2', cmap='BuGn', figsize=(5,5), linewidth=shp_sub['Case1_2'], edgecolor='0.8', vmin=0, vmax=1)
Run Code Online (Sandbox Code Playgroud)
这意味着厚度和颜色代码应该相互匹配。
我已经尝试过这个:
shp_sub.plot(column='Case1_2', cmap='BuGn', figsize=(5,5), linewidth=1, edgecolor='0.8', vmin=0, vmax=1)
Run Code Online (Sandbox Code Playgroud)
当我尝试这个时,我没有得到一对一的。
shp_sub.plot(column='Case1_2', cmap='BuGn', figsize=(5,5), linewidth=shp_sub['Case1_2'], edgecolor='0.8', vmin=0, vmax=1)
Run Code Online (Sandbox Code Playgroud)
我正在 R 中绘制栅格数据,当我调整到我正在处理的区域时,R 显示不想被切断的 ylim。
我试过:
# set lon lat
ylim=c(-4,2)
xlim=c(118,126)
plot(pm10_mean,xlim=xlim, ylim=ylim)
plot(shp, add=TRUE)
plot(shp2, add=TRUE)
Run Code Online (Sandbox Code Playgroud)
但我得到了这样的照片
如何删除 2 以上和 -4 以下的可用空间?我只想在xlim和中绘制区域ylim
我有一个多边形的形状文件,我想找到每个多边形的质心,但我得到的是整个形状文件的质心。
我使用以下代码行将我的 csv 文件转换为 shapefile (请参阅此问题Converting CSV file to shapefile - but Want Polygon not Points ):
df <- as.data.frame(read_csv("/Users/alan/Desktop/shapes.csv"))
df1 <- lapply(split(df, df$shape), function(x) { coords <- as.matrix(cbind(x$longitude,
x$latitude)); rbind(coords, coords[1,])})
Coord_Ref <- st_crs(3035)
plot_locations_df <- st_multipolygon(x=list(df1))
plot_locations_df <- st_sfc(plot_locations_df, crs = Coord_Ref)
plot(st_geometry(plot_locations_df))
plot(st_geometry(plot_locations_df, col = sf.colors(12, categorical=TRUE), border='grey',
axes=TRUE))
plot(st_geometry(st_centroid(plot_locations_df)), pch = 3, col = 'red', add=TRUE)
Run Code Online (Sandbox Code Playgroud)
我的数据框如下所示:
structure(list(shape = c(1.1, 1.1, 1.1, 1.1, 2.1, 2.1, 2.1, 2.1,
3.1, 3.1, 3.1, 3.1, 4.1, 4.1, 4.1, 4.1, …Run Code Online (Sandbox Code Playgroud) 我有多个 shapefile (.shp) 及其辅助文件,我想将它们显示在 Leaflet 地图上。shapefile 使用不同的坐标参考系统 (CRS),我很难掌握在地图上显示事物的最直接、最可靠的方式。在geodjango教程中,DataSource用于加载shapefile,然后对其进行操作。然而,在他们的示例中,他们只检索单个特征的几何形状,而不是整个 shapefile 的几何形状。我已经使用了PyShp,并且可以使用以下内容显示地图:
sf = shapefile.Reader(filename)
shapes = sf.shapes()
geojson = shapes.__geo_interface__
geojson = json.dumps(geojson)
Run Code Online (Sandbox Code Playgroud)
但是,当 CRS 不是 WGS84 时,这会失败,事情不起作用,而且我不知道如何转换它。
阅读更多内容后,这篇文章抱怨了 CRS 支持和 pyshp,并建议使用 ogr2ogr。
因此,在尝试了解这些选项之后,我看到使用 Datasource、pyshp 和 ogr2ogr 作为可能的选项,但我不知道哪个选项真正最有意义。
我想要的只是使用 Django 将 .shp 文件转换为使用 WGS84 的 geojson 字符串,以便我可以将其包含在使用 Leaflet 的 HTML 页面上。
有经验的人可以推荐一条特定的路线吗?