标签: shapefile

如何在elasticsearch中索引geojson文件?

我正在尝试使用 PYTHON 以 geojson、csv 文件和形状文件的形式将空间数据存储到 elasticsearch 中。我是 elasticsearch 的新手,即使在遵循文档后我也无法成功索引它。任何帮助,将不胜感激。

示例 geojson 文件:

{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "ID_0": 105,
        "ISO": "IND",
        "NAME_0": "India",
        "ID_1": 1288,
        "NAME_1": "Telangana",
        "ID_2": 15715,
        "NAME_2": "Telangana",
        "VARNAME_2": null,
        "NL_NAME_2": null,
        "HASC_2": "IN.TS.AD",
        "CC_2": null,
        "TYPE_2": "State",
        "ENGTYPE_2": "State",
        "VALIDFR_2": "Unknown",
        "VALIDTO_2": "Present",
        "REMARKS_2": null,
        "Shape_Leng": 8.103535,
        "Shape_Area": 127258717496
      },
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              79.14429367552918,
              19.500257885106404
            ],
            [
              79.14582245808431,
              19.498859172536427
            ],
            [
              79.14600496956801,
              19.498823981691853
            ],
            [
              79.14966523737327, …
Run Code Online (Sandbox Code Playgroud)

shapefile geojson elasticsearch

5
推荐指数
1
解决办法
6289
查看次数

在 R 中的栅格图层上绘制 shapefile

我想用顶部形状文件中的点绘制一个栅格图层。我已经检查了之前的答案,但仍然有问题。我可以毫无问题地分别绘制点形状文件和栅格图层,但不能一起绘制。

据我所知,它们应该位于相同的投影和位置。

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)

plot r raster shapefile

5
推荐指数
1
解决办法
4773
查看次数

在 ggplot2 上叠加 ggmap 、 geom_polygon(shape file)

我有一个形状文件,我想用 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)

在此输入图像描述

我的代码有什么问题吗?谢谢

r shapefile ggplot2 ggmap

5
推荐指数
1
解决办法
1286
查看次数

使用 Jupyter Notebook 中的 PySpark 从 AWS EMR 集群读取存储在 AWS S3 中的解压缩 Shapefile

我对 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)

gis amazon-s3 shapefile python-3.x pyspark

5
推荐指数
1
解决办法
2330
查看次数

基于 geopandas、python 的 shapefile 属性的线宽

我想绘制一个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)

图1

当我尝试这个时,我没有得到一对一的。

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)

图2

python shapefile geopandas

5
推荐指数
1
解决办法
6046
查看次数

如何在R中的绘图栅格中设置ylim和xlim

我正在 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

plot r raster shapefile

5
推荐指数
1
解决办法
3229
查看次数

如何使用 sf 库找到多边形的质心

我有一个多边形的形状文件,我想找到每个多边形的质心,但我得到的是整个形状文件的质心。

在此输入图像描述

我使用以下代码行将我的 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)

r shapefile shapes r-sf

5
推荐指数
1
解决办法
2901
查看次数

Geodjango:如何加载 .shp 文件并使用正确的 CRS 转换为 geojson?

我有多个 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 页面上。

有经验的人可以推荐一条特定的路线吗?

python django shapefile geodjango coordinate-transformation

5
推荐指数
1
解决办法
2659
查看次数

我在哪里可以找到.zip格式的旧R包?

我在哪里可以找到.zip格式的旧R包?

以CRAN为例: http://cran.r-project.org/src/contrib/Archive/shapefiles

只有.tar.gz文件来源,我必须安装旧版本,shapefiles因为已经删除了一些文件.

r package shapefile cran

4
推荐指数
2
解决办法
1834
查看次数

如何在OpenStreetMap中下载中国的县界?

有没有办法在OpenStreetMap中下载关于中国的eh县界的shp格式文件?

boundary shapefile openstreetmap

4
推荐指数
1
解决办法
4188
查看次数