我想将展平数组中的索引转换为多维数组中的坐标.
示例: 在以下尺寸为[3,3]的二维数组中:
[
[ -, -, - ],
[ *, -, - ],
[ -, -, - ]
]
Run Code Online (Sandbox Code Playgroud)
坐标*为[0,1].如果我们将此数组展平为:
[ -, -, -, *, -, -, -, -, - ]
Run Code Online (Sandbox Code Playgroud)
坐标(或指数)*变为3.我们怎么能做相反的事情呢?也就是说,一种方法:
index_to_coordinates([3, 3], 3) # => [0, 1]
Run Code Online (Sandbox Code Playgroud) 我有一组反映图像上已知位置的坐标.我们称之为模板图像.它有一个独特的条形码和方向标记(也在坐标数组中).
打印,扫描图像并将其反馈到我的应用程序中进行检测.在打印和扫描期间,图像可以以三种方式转换; 翻译,轮换和规模.
假设我可以在失真图像上找到方向标记,我如何使用矩阵变换来获得剩余坐标的相对位置?
我之前在SO上发布了这个问题,但是让它太复杂,无法理解我想要的东西.
编辑
namespace MatrixTest
{
using System;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Collections.Generic;
public static class Program
{
public static void Main ()
{
Template template = new Template(); // Original template image.
Document document = new Document(); // Printed and scanned distorted image.
template.CreateTemplateImage();
// The template image is printed and scanned. This method generates an example scan or this question.
document.CreateDistortedImageFromTemplateImage();
// Stuck here.
document.Transform();
// Draw transformed points on the image …Run Code Online (Sandbox Code Playgroud) 我正在构建一个使用GMaps API v3的应用程序,并利用地理编码功能,我不知道它是否更好地存储在数据库中:
你会推荐什么?
提前致谢!
google-maps geocoding geolocation coordinates street-address
我得到了一个.txt文件,其中包含格式为"x y"的点坐标.它们代表了飞机上的一团点.我的想法是减少云的"密度",将点数减少一半.我正在使用linux,所以我想用sed删除一半的行,但只删除偶数或奇数或两行的一行.为了更清楚,我将发布一个例子:
之前
435.225 108.891
435.212 108.894 <-- to delete
435.225 108.894
435.238 108.894 <-- to delete
435.3 108.894
435.212 108.897 <-- to delete
435.238 108.897
435.288 108.897 <-- to delete
Run Code Online (Sandbox Code Playgroud)
后
435.225 108.891
435.225 108.894
435.3 108.894
435.238 108.897
Run Code Online (Sandbox Code Playgroud) 我想(有效地)找到比某距离更近的所有点对max_d。我当前使用的方法cdist是:
import numpy as np
from scipy.spatial.distance import cdist
def close_pairs(X,max_d):
d = cdist(X,X)
I,J = (d<max_d).nonzero()
IJ = np.sort(np.vstack((I,J)), axis=0)
# remove diagonal element
IJ = IJ[:,np.diff(IJ,axis=0).ravel()<>0]
# remove duplicate
dt = np.dtype([('i',int),('j',int)])
pairs = np.unique(IJ.T.view(dtype=dt)).view(int).reshape(-1,2)
return pairs
def test():
X = np.random.rand(100,2)*20
p = close_pairs(X,2)
from matplotlib import pyplot as plt
plt.clf()
plt.plot(X[:,0],X[:,1],'.r')
plt.plot(X[p,0].T,X[p,1].T,'-b')
Run Code Online (Sandbox Code Playgroud)
但是我认为这太过分了(不是很容易理解),因为大部分工作只是为了消除与自己的距离和重复项。
我的主要问题是:还有更好的方法吗?
(注:输出(类型array,set......)并不重要,在这一点上)
我当前的想法是使用pdist,它返回一个仅包含正确对的精简距离数组。但是,一旦我k从压缩距离数组中找到了合适的坐标,我该如何计算i,j它等同于哪些对呢?
因此,另一个问题是:是否有一种简单的方法来获取相对于pdist输出条目的坐标对列表:
我在具有4个节点的地图上定义了一个矩形。
每个节点都是一对(X,Y)
X:纬度
Y:经度
X,Y:地理坐标(具有双精度值)
我想检查点 (X,Y)是否在该矩形内。
该点将是用户的当前位置(当前位置来自手机的GPS输出)
是否有特定的数学公式?如何确定特定点是否属于矩形?
原因我想在C#中实现它。
我知道有很多关于按多个值排序javascript数组的问题,但没有一个答案解决了我的问题.
我有一个坐标数组,如:
x | y
--------
10 20
12 18
20 30
5 40
100 2
Run Code Online (Sandbox Code Playgroud)
如何获得最接近原点的坐标?
javascript arrays google-maps coordinates coordinate-systems
我正在尝试计算2个坐标之间的距离.为此我做:
func setupLocationManager() {
if CLLocationManager.authorizationStatus() == .NotDetermined {
locationManager.requestWhenInUseAuthorization()
}
locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()
}
func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let latitude = locations.last?.coordinate.latitude
let longitude = locations.last?.coordinate.longitude
let myLocation = CLLocation(latitude: latitude!, longitude: longitude!)
let targetLocation = CLLocation(latitude: 41.4381022, longitude: 46.604910)
let distance = myLocation.distanceFromLocation(targetLocation)
print(distance)
}
Run Code Online (Sandbox Code Playgroud)
我正在检查谷歌地图有13公里的距离!但我的应用程序显示我2-3公里!
我怎样才能改善这一点?
我在R中有几个数据帧.第一个数据帧包含市场上一组lat和long坐标的计算凸包(由R中的chull提供).它看起来像这样:
MyGeo<- "Part of Chicago & Wisconsin"
Longitude <- c(-90.31914, -90.61911, -89.37842, -88.0988, -87.44875)
Latitude <- c(38.45781, 38.80097, 43.07961, 43.0624,41.49182)
dat <- data.frame(Longitude, Latitude, MyGeo)
Run Code Online (Sandbox Code Playgroud)
第二个是纬度和纵坐标的邮政编码(美国人口普查网站提供).它看起来像这样:
CensuseZip <- c("SomeZipCode1","SomeZipCode2","SomeZipCode3","SomeZipCode4","SomeZipCode5","SomeZipCode6","SomeZipCode7")
Longitude2 <- c(-131.470425,-133.457924,-131.693453,-87.64957,-87.99734,-87.895,-88.0228)
Latitude2 <- c(55.138352,56.239062,56.370538,41.87485,42.0086,42.04957,41.81055)
cen <- data.frame(Longitude2, Latitude2, CensuseZip)
Run Code Online (Sandbox Code Playgroud)
现在我相信第一个数据表为我提供了一个多边形或边框,我应该可以使用它来识别属于该边界的邮政编码.理想情况下,我想创建一个类似于下面的第三个数据表:
Longitude2 Latitude2 CensusZip MyGeo
-131.470425 55.138352 SomeZipCode1
-133.457924 56.239062 SomeZipCode2
-131.693453 56.370538 SomeZipCode3
-87.64957 41.87485 SomeZipCode4 Part of Chicago & Wisconsin
-87.99734 42.0086 SomeZipCode5 Part of Chicago & Wisconsin
-87.895 42.04957 SomeZipCode6 Part of Chicago & Wisconsin …Run Code Online (Sandbox Code Playgroud)