该PDF似乎有足够的地理空间信息可供其阅读 OGR 图书馆,你可以通过 sf 包:
OGR
sf
> library(sf) > plan = st_read("./7964_FLORIDA KEYS OUTLET MKTPLACE_CurrentWebLeasePlan-1_1.pdf") Reading layer `~Remaining_objects' from data source `/home/rowlings/Downloads/SO/7964_FLORIDA KEYS OUTLET MKTPLACE_CurrentWebLeasePlan-1_1.pdf' using driver `PDF' Simple feature collection with 998 features and 0 fields geometry type: GEOMETRY dimension: XY bbox: xmin: 71.1875 ymin: 52.47917 xmax: 2478.271 ymax: 1613.917 epsg (SRID): NA proj4string: NA
那里有998种各种功能 - 线条,多边形等。您可以绘制它:
> plot(plan$geometry) Error in CPL_geos_is_empty(st_geometry(x)) : Evaluation error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4.
并暂时忽略错误。坐标系不是以地球为参考,它在左下角有一个(0,0)原点:
> axis(1) > axis(2)
如果你想要,你可以提取计划的一部分,并绘制那些:
> plot(plan[1:100,])
但是没有关于什么功能是什么的元数据。你所拥有的就是几何学。 “套房”只是一个房间吗?你会的
您可以使用 geom_sf 从 ggplot 映射这个,但当它失败并出现该错误时,它没有绘制任何内容:
geom_sf
ggplot
> ggplot(plan) + geom_sf() Error in CPL_geos_is_empty(st_geometry(x)) : Evaluation error: IllegalArgumentException: Invalid number of points in LinearRing found 3 - must be 0 or >= 4.
我将错误跟踪到功能编号638,所以如果你想使用它,请删除它 ggplot :
> ggplot(plan[-638,]) + geom_sf() >
我认为这与您自动退出PDF有关。如果要从PDF中的文本中编写区域的名称将会很棘手。该文本未被阅读 OGR 我能想到的onyl方法是使用PDF-to-Text转换器来获取文本及其位置,然后将位置与多边形要素匹配,但这可能不起作用,因为坐标系可能不匹配。 ......所以手工操作可能更容易。将PDF加载到QGIS中(这应该可以使用,因为它使用 OGR )然后在属性表中创建新列,并通过每个列添加商店名称和信息。然后你可以保存到shapefile(或更好的地理包装),你可以读入R并用ggplot映射...