我有一个世界各国的shapefile,从这里下载.我可以用R绘制它
countries <- readOGR("shp","TM_WORLD_BORDERS-0.3",encoding="UTF-8",stringsAsFactors=F)
par(mar=c(0,0,0,0),bg=rgb(0.3,0.4,1))
plot(countries,col=rgb(1,0.8,0.4))
Run Code Online (Sandbox Code Playgroud)
现在我想把它绘制在正交投影(从外太空看到的地球),所以我正在尝试
countries <- spTransform(countries,CRS("+proj=ortho +lat_0=-10 +lon_0=-60"))
Run Code Online (Sandbox Code Playgroud)
我还使用了与X_0和y_0参数(如说这里),但我总是得到错误:
non finite transformation detected:
[1] 45.08332 39.76804 Inf Inf
Erro em .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, :
failure in Polygons 3 Polygon 1 points 1
Além disso: Mensagens de aviso perdidas:
In .spTransform_Polygon(input[[i]], to_args = to_args, from_args = from_args, :
108 projected point(s) not finite
Run Code Online (Sandbox Code Playgroud)
有时在第3个多边形,有时在第7个.那些"Inf"来自哪里?我需要更改任何参数吗?我想像这样绘制地图

但是集中在南美洲之上.谢谢你的帮助!
我想开发一个小程序,检查来自shapefile的哪些多边形与给定的矩形相交。该程序将在网站中使用(使用PHP的exec()命令)。问题是,由于我未知的原因,我的网络服务器无法安装GDAL。因此,我无法链接到共享库。相反,我必须链接到静态库,但是没有给出。
我已经从此处(2.3.2 Latest Stable Release-2018年9月)下载了GDAL源代码,并从此处遵循了构建说明。因为我已经在GDAL上运行了Debian,并且不想弄乱它,所以我遵循了“在非根目录下安装”的说明,并对“某些注意事项”部分中的最后一项进行了一些调整:
cd /home/rodrigo/Downloads/gdal232/gdal-2.3.2
mkdir build
./configure --prefix=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/ --without-ld-shared --disable-shared --enable-static
make
make install
export PATH=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/bin:$PATH
export LD_LIBRARY_PATH=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib:$LD_LIBRARY_PATH
export GDAL_DATA=/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/share/gdal
/usr/bin/gdalinfo --version
build/bin/gdalinfo --version
Run Code Online (Sandbox Code Playgroud)
第一个/usr/bin/gdalinfo --version给出2.1.2(先前安装的版本)。第二个build/bin/gdalinfo --version给出了2.3.2(刚刚构建的版本)。
到目前为止,我的程序仅使用ogrsf_frmts.h标头,该标头位于/usr/include/gdal/或/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/include/目录中,具体取决于构建。没有ogrsf_frmts.a文件,只有一个libgdal.a。这是我应该链接的文件吗?如果是这样,怎么办?到目前为止,我已经尝试过:
gcc geofragc.cpp -l:libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l:libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l:/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -Wl,-Bstatic -l/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp /home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -l/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
gcc geofragc.cpp -l:/home/rodrigo/Downloads/gdal232/gdal-2.3.2/build/lib/libgdal.a
Run Code Online (Sandbox Code Playgroud)
但没有任何效果。我想念什么?
编辑
第二次试用(gcc geofragc.cpp …
我想使用似乎比较常见的色标(在这里和这里查看),但是我在任何地方都找不到它。这不是Rainbow()或heat.colors()或此处的任何其他内容;并且http://colorbrewer2.org/也不会显示它(或者至少我找不到它)。有什么帮助吗?如果在基本软件包中,那就更好了!
我有亚马逊州(巴西)和该州六大河流(Negro、Solimões、Amazonas、Madeira、Purus 和 Juruá)的其他形状文件。我想使用河流划分州,以获得河流间区域(马德拉-普鲁斯、普鲁斯-朱鲁等)。我想获得由这些河流划定的最后 6 个区域,每个区域作为不同的多边形。我怎么做?

我只找到“裁剪”算法,这些算法给了我州内河流的面积,这不是我想要的。
我正在尝试使用这个问题.物理库.我正在使用他们的"入门"教程,但它无法找到画布.
这是我的HTML:
<html>
<head>
<meta charset="UTF-8">
<title>Physics test</title>
</head>
<script type="text/javascript" src="./lib/matter-0.8.0.js"></script>
<script type="text/javascript">
// Matter.js module aliases
var Engine = Matter.Engine,
World = Matter.World,
Bodies = Matter.Bodies;
// create a Matter.js engine
var engine = Engine.create(document.body);
// create two boxes and a ground
var boxA = Bodies.rectangle(400, 200, 80, 80);
var boxB = Bodies.rectangle(450, 50, 80, 80);
var ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true });
// add all of the bodies to …Run Code Online (Sandbox Code Playgroud) 我在R中使用ggmap库.我正在尝试用它下载一个矩形地图,但我知道它会给我一个正方形.我只需要返回方块的边界框.
library(ggmap)
map <- get_map(c(-65.7,-3.1,-64.4,-2.3),maptype="satellite",filename="map.png")
str(map)
chr [1:1280, 1:1280] "#294829" "#294829" "#2D512D" "#264425" ...
- attr(*, "class")= chr [1:2] "ggmap" "raster"
- attr(*, "bb")='data.frame': 1 obs. of 4 variables:
..$ ll.lat: num -3.14
..$ ll.lon: num -65.5
..$ ur.lat: num -2.26
..$ ur.lon: num -64.6
Run Code Online (Sandbox Code Playgroud)
对象图有两个类"ggmap"和"raster".我不能在其中使用@或$.那怎么能从"bb"子对象访问ll.lat和其他属性?
我需要读取一些文本文件(以制表符分隔),在某些字段中有一些回车.
如果我使用read.table,它会给我一个错误:
line 6257 did not have 20 elements
Run Code Online (Sandbox Code Playgroud)
如果我使用read.csv,它不会给出错误,但会在该位置创建一个新行,将下一个字段放在新行的第一个字段中.
我怎么能避免这个?我无法改变文件本身(脚本将在其他地方运行).断字符串也没有引号(文件中没有字符串).一种选择是将回车读作单个空格,或者作为\n,但如何?
我在PostgreSQL(9.5.1)中有以下查询:
select e.id, (select count(id) from imgitem ii where ii.tabid = e.id and ii.tab = 'esp') as imgs,
e.ano, e.mes, e.dia, cast(cast(e.ano as varchar(4))||'-'||right('0'||cast(e.mes as varchar(2)),2)||'-'|| right('0'||cast(e.dia as varchar(2)),2) as varchar(10)) as data,
pl.pltag, e.inpa, e.det, d.ano anodet, coalesce(p.abrev,'')||' ('||coalesce(p.prenome,'')||')' determinador, d.tax, coalesce(v.val,v.valf)||' '||vu.unit as altura,
coalesce(v1.val,v1.valf)||' '||vu1.unit as DAP, d.fam, tf.nome família, d.gen, tg.nome gênero, d.sp, ts.nome espécie, d.inf, e.loc, l.nome localidade, e.lat, e.lon
from esp e
left join det d on e.det = d.id
left join tax tf …Run Code Online (Sandbox Code Playgroud) postgresql performance pattern-matching query-performance postgresql-performance
我想用一种颜色画一条线,用另一种颜色画下一条线。但是当我第二次调用中风()时,第一条线又被绘制了!我怎样才能避免它?这是我的代码:
var canv = document.getElementById("canvas");
var ctx = canv.getContext("2d");
ctx.moveTo(0,0);
ctx.lineTo(100,100);
ctx.strokeStyle = "#FF0000";
ctx.stroke();
ctx.moveTo(100,100);
ctx.lineTo(100,200);
ctx.strokeStyle = "#999999";
ctx.stroke();
Run Code Online (Sandbox Code Playgroud)
提前致谢!
var i,j;
for (i=0; i<30; i++) {
for (j=0; j<10; j++) {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
与
for (var i=0; i<30; i++) {
for (var j=0; j<10; j++) {
// do something
}
}
Run Code Online (Sandbox Code Playgroud)
由于javascript的范围逻辑,第二种方式创建并销毁了j次30次?我更喜欢使用第一种方式,但我不知道是否存在差异.在那儿?
r ×5
javascript ×3
canvas ×2
c++ ×1
colors ×1
csv ×1
divide ×1
gcc ×1
gdal ×1
ggmap ×1
heatmap ×1
html ×1
html5 ×1
map ×1
orthographic ×1
performance ×1
plot ×1
polygon ×1
postgresql ×1
projection ×1
read.csv ×1
read.table ×1
variables ×1