Я строил данные в ggpplot, но обнаружил, что шкалы y и x не совпадают с показанными на следующем изображении
расстояние между точками на Y и X не то же самое, как я могу это исправить?
Здесь я попробовал:
ggplot(data=df, aes(y=Latitude, x=Longitude)) +
geom_raster(aes(fill=AOD), interpolate = TRUE) +
scale_y_continuous(breaks = c(-4,-2,0,2), labels = c("4LS","2LS","0","2LU"),
expand = c(0,0)) +
scale_x_continuous(breaks =c(118,120,122,124),labels = c("118BT","120BT","122BT","124BT"),
expand = c(0,0)) +
theme(plot.title = element_text(hjust = 0.5)) +
labs(y = "Lintang", x = "Bujur" ) +
coord_equal(xlim=c(0,125.8),ylim=c(0,2)) +
scale_fill_gradientn(expression(paste("Indeks AOD (",alpha,")")),colours=warna,na.value = "transparent"
,limits=c(0,1), breaks=seq(0.1, 0.9, by=0.1), oob = scales::squish) +
geom_path(data = shapefile_df3, aes(x = long, y = lat, group = group),
color = 'black', fill= "gray") +
theme(legend.key.size = unit(1.5, "cm"),
legend.key.width = unit(0.5,"cm")) +
labs(title = expression("Total Aerosol Optical Depth at 550nm"),
subtitle = paste(waktu[i]," ",
"SULAWESI TENGAH"),
caption = paste(validasi," ",
"Diolah oleh: Stasiun GAW Palu \n Sumber Data: ECMWF")) +
theme (plot.title = element_text(hjust = 0.5,size=14 ,face = "bold"),
plot.subtitle = element_text(hjust = 1, size=8.5),
plot.caption = element_text(hjust = 1, size=8.5)) +
annotation_custom(img, xmin = 126.1, xmax = 127.6, ymin = -5, ymax = -4) +
coord_cartesian(clip = "off") +
theme(plot.margin = unit(c(1, 1, 3, 1), "lines"))
Я пробовал с дополнениями coord_equal(xlim=c(0,125.8),ylim=c(0,2))
, но все тот же
Вот пример данных:
new("RasterLayer", file = new(".RasterFile", name = "D:\\Kimia_Atmosfer\\data_aod\\data_nc\\z_cams_c_ecmf_20200416000000_prod_fc_sfc_000_aod550.nc",
datanotation = "FLT4S", byteorder = "little", nodatavalue = 9.96920996838687e+36,
NAchanged = FALSE, nbands = 1L, bandorder = "BIL", offset = 0L,
toptobottom = FALSE, blockrows = 0L, blockcols = 0L, driver = "netcdf",
open = FALSE), data = new(".SingleLayerData", values = logical(0),
offset = 0, gain = 1, inmemory = FALSE, fromdisk = TRUE,
isfactor = FALSE, attributes = list(), haveminmax = FALSE,
min = Inf, max = -Inf, band = 1L, unit = "~", names = "Total.Aerosol.Optical.Depth.at.550nm"),
legend = new(".RasterLegend", type = character(0), values = logical(0),
color = logical(0), names = logical(0), colortable = logical(0)),
title = character(0), extent = new("Extent", xmin = -0.200000003394614,
xmax = 359.80000610691, ymin = -90.2, ymax = 90.2), rotated = FALSE,
rotation = new(".Rotation", geotrans = numeric(0), transfun = function ()
NULL), ncols = 900L, nrows = 451L, crs = new("CRS", projargs = "+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0"),
history = list(), z = list("2020-04-16 01:13:14"))
# load shp
shp2 <- readShapePoly(paste0(alamat_file,"shp_indonesia/"
,"IDN_adm1.shp"))
shp <- readShapePoly(paste0(alamat_file,"shp_kab_sulteng/"
,"Kabupaten_Sulteng_2010.shp"))
# Create the clipping polygon
CP <- as(extent(117.8, 125.8, -4.2, 1.8), "SpatialPolygons")
proj4string(CP) <- CRS(proj4string(shp2))
# crop to sulteng
aod_sulteng <- crop(dataku, CP)
#convert the raster to points for plotting
map.p <- rasterToPoints(aod_sulteng)
#Make the points a dataframe for ggplot
df <- data.frame(map.p)
#Make appropriate column headings
colnames(df) <- c("Longitude", "Latitude", "AOD")